package quant.smart.crawl.cmd;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public class ClientContext {
	
	volatile boolean isSSL=false;//是否是https连接
	volatile String encoding="utf-8";//编码格式
	
	//cookies
	Map<String,String> cookies =new ConcurrentHashMap<String,String>();	
	//parameters额外参数
	Map<String,String> parameters =new ConcurrentHashMap<String,String>();
	
	public void addCookie(String name,String val){
		cookies.put(name, val);
	}
	public void addParameter(String name,String val){
		parameters.put(name, val);
	}	
	public Map<String, String> getCookies() {
		return cookies;
	}	
	public String getCookiesStr(){
		StringBuffer cookiesBuf = new StringBuffer();
		for (Map.Entry<String, String> c : getCookies().entrySet()) {
			cookiesBuf.append(c.getKey() + "=" + c.getValue() + ";");
		}
		return cookiesBuf.toString();
	}
	public void setCookies(Map<String, String> cookies) {
		this.cookies = cookies;
	}
	public Map<String, String> getParameters() {
		return parameters;
	}
	public void setParameters(Map<String, String> parameters) {
		this.parameters = parameters;
	}
	public boolean isSSL() {
		return isSSL;
	}
	public void setSSL(boolean isSSL) {
		this.isSSL = isSSL;
	}

	public String getEncoding() {
		return encoding;
	}

	public void setEncoding(String encoding) {
		this.encoding = encoding;
	}
}
